package demo3;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: atp
 * Date: 2022-10-30
 * Time: 17:30
 */
interface IFly {
    void flying();
}
interface ISwimming {
    void swimming();
}
interface IRunning {
    void running();
}
class Animal {
    public String name;
    public int age;

    public Animal(String name, int age) {
        this.name = name;
        this.age = age;
    }

    public void eat() {
        System.out.println("吃饭");
    }

}
class Dog extends Animal implements IRunning,ISwimming {
    public Dog(String name,int age) {
        super(name,age);
    }
    @Override
    public void swimming() {
        System.out.println(name + " 正在游泳");
    }

    @Override
    public void running() {
        System.out.println(name + " 正在跑步");
    }
}
class Bird extends Animal implements IFly {
    public Bird(String name, int age) {
        super(name, age);
    }

    @Override
    public void flying() {
        System.out.println(name + " 正在飞");
    }
}
class Duck extends Animal implements ISwimming,IRunning,IFly {

    public Duck(String name, int age) {
        super(name, age);
    }

    @Override
    public void flying() {
        System.out.println(name + " 正在飞");
    }

    @Override
    public void swimming() {
        System.out.println(name + " 正在游泳");
    }

    @Override
    public void running() {
        System.out.println(name + " 正在跑步");
    }
}
class robot implements IRunning {

    @Override
    public void running() {
        System.out.println("机器人正在跑");
    }
}
public class Test6 {
    public static void walk(IRunning iRunning) {
        iRunning.running();
    }
    public static void main(String[] args) {
        walk(new Dog("hello",10));
        walk(new Duck("666",18));
        walk(new robot());
    }
}
